package rcp.iphex2.ui.projectexplorer.commandhandler;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.handlers.HandlerUtil;

import rcp.iphex2.SharedIds;
import rcp.iphex2.ui.projectexplorer.ProjectExplorerView;

/**
 * Internal command handler to update the project explorer view
 * 
 */
public class UpdateHandler extends AbstractHandler {

	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
		String PROJECT_EXPLORER_VIEW_ID = SharedIds.PROJECT_EXPLORER_VIEW_ID;
		IViewPart iViewPart = HandlerUtil.getActivePart(event).getSite().getPage().findView(PROJECT_EXPLORER_VIEW_ID);

		final ProjectExplorerView projectExplorerView = (ProjectExplorerView) iViewPart;

		if (projectExplorerView != null) {
			projectExplorerView.update(true);
		}
		return null;

	}

}
